<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>利用父构造函数实现属性继承</title>
		<script type="text/javascript">
			function Father(username,age) {
				this.username = username;
				this.age = age;
			}
			function Son(username,age,scroe) {
				//利用call()方法改变父构造函数的this指向实现属性的继承
				Father.call(this,username,age);
				this.scroe = scroe;
				
			}
			Father.prototype.dance = function() {
				console.log('dance');
			}
//			Son.prototype = Father.prototype;
			Son.prototype = new Father();   //将father实例对象给Son，但是要将son中的prototype的constructor指向Son本身,因为Father中的prototype的contructor会把Son中的Contructor覆盖
			Son.prototype.constructor = Son;
			Son.prototype.sing = function() {
				console.log('sing');
			}
			
			
			var son = new Son('张学友',19,100);
			console.log(son.__proto__)
			console.log(Son.prototype)
			console.log(Father.prototype)
			
		</script>
	</head>
	<body>
	</body>
</html>
